<template>
    <svg :class="svgClass" aria-hidden="true">
        <use :xlink:href="iconClassName" :fill="color"></use>
    </svg>
</template>

<script setup>
import { computed, defineProps } from 'vue'

const props = defineProps({
    // 添加自定义类名
    className: {
        type: String,
        default: ''
    },
    // iconfont中的名字
    iconName: {
        type: String,
        required: true
    },
    color:{
        type: String,
        default: '#eee'
    }
})

const svgClass = computed(() => {
    if (props.className) {
        return `svg-icon-font ${ props.className }`
    } else {
        return 'svg-icon-font'
    }
})
const iconClassName = computed(() => `#${ props.iconName }`)
</script>

<style scoped>
.svg-icon-font {
    width: 14px;
    height:14px;
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
    color: #333;
}
</style>
